﻿// //------------------------------------------------------------------------------
// // <copyright file="" company="Dascoba Development">
// //  Copyright © Dascoba Development 2010
// // </copyright>
// //------------------------------------------------------------------------------
namespace Dascoba.Umb.FileManager.Support
{
    using System.IO;

    using Dascoba.Umb.FileManager.Actions;

    using umbraco.BusinessLogic.Actions;

    public static class Menus
    {
        /// <summary>
        ///   Gets the umbraco menu.
        /// </summary>
        /// <value>The umbraco menu.</value>
        internal static ContextMenu UmbracoMenu
        {
            get
            {
                return new ContextMenu("umbracoMenu", "umbracoFolder", "cm_default")
                    { ActionNew.Instance, ActionRefresh.Instance };
            }
        }

        /// <summary>
        ///   Gets the folder default menu.
        /// </summary>
        /// <value>The folder default menu.</value>
        internal static ContextMenu FolderDefaultMenu
        {
            get
            {
                return new ContextMenu("folderMenu", "folder", "cm_default")
                    {
                        ActionCreateFolder.Instance,
                        ActionUploadFiles.Instance,
                        ContextMenuSeperator.Instance,
                        ActionImportMediaFolder.Instance,
                        ContextMenuSeperator.Instance,
                        ActionDeleteFolder.Instance
                    };
            }
        }

        /// <summary>
        ///   Gets the folder no files menu.
        /// </summary>
        /// <value>The folder no files menu.</value>
        internal static ContextMenu FolderNoFilesMenu
        {
            get
            {
                return new ContextMenu("folderEmptyMenu", "folderEmpty", "cm_default")
                    {
                        ActionCreateFolder.Instance,
                        ActionUploadFiles.Instance,
                        ContextMenuSeperator.Instance,
                        ActionDeleteFolder.Instance
                    };
            }
        }

        /// <summary>
        ///   Gets the current folder menu.
        /// </summary>
        /// <value>The current folder menu.</value>
        internal static ContextMenu CurrentFolderMenu
        {
            get
            {
                return new ContextMenu("currentFolderMenu", "currentFolder", "cm_default")
                    { ActionCreateFolder.Instance, ActionUploadFiles.Instance };
            }
        }

        /// <summary>
        ///   Gets the root folder menu.
        /// </summary>
        /// <value>The root folder menu.</value>
        internal static ContextMenu RootFolderMenu
        {
            get
            {
                return new ContextMenu("rootFolderMenu", "rootFolder", "cm_default")
                    { ActionCreateRootFolder.Instance, ActionUploadRootFiles.Instance };
            }
        }

        /// <summary>
        ///   Gets the recycle bin menu.
        /// </summary>
        /// <value>The recycle bin menu.</value>
        internal static ContextMenu RecycleBinMenu
        {
            get
            {
                return new ContextMenu("recycleBinMenu", "recycleBin", "cm_default") { ActionEmptyRecycleBin.Instance };
            }
        }

        /// <summary>
        ///   Gets the recycled item menu.
        /// </summary>
        /// <value>The recycled item menu.</value>
        internal static ContextMenu RecycledItemMenu
        {
            get
            {
                return new ContextMenu("recycledItemMenu", "recycledItem", "cm_default")
                    {
                        ActionRestoreRecycledItem.Instance,
                        ContextMenuSeperator.Instance,
                        ActionEmptyRecycleBin.Instance
                    };
            }
        }

        /// <summary>
        ///   Gets the file default menu.
        /// </summary>
        /// <value>The file default menu.</value>
        internal static ContextMenu FileDefaultMenu
        {
            get
            {
                return new ContextMenu("fileMenu", "file", "cm_default")
                    { ActionImportMedia.Instance, ContextMenuSeperator.Instance, ActionDeleteFile.Instance };
            }
        }

        /// <summary>
        ///   Gets the file archive menu.
        /// </summary>
        /// <value>The file archive menu.</value>
        internal static ContextMenu FileArchiveMenu
        {
            get
            {
                var archiveFileMenu = FileDefaultMenu;

                archiveFileMenu.MenuId = "archiveFileMenu";
                archiveFileMenu.ItemClass = "archiveFile";
                archiveFileMenu.Add(ContextMenuSeperator.Instance);
                archiveFileMenu.Add(ActionExtractArchive.Instance);

                return archiveFileMenu;
            }
        }

        /// <summary>
        ///   Gets the menu by extension.
        /// </summary>
        /// <param name = "fileInfo">The file info.</param>
        /// <returns></returns>
        internal static ContextMenu GetMenuByFileType(FileInfo fileInfo)
        {
            var extension = Util.GetSimpleExtension(fileInfo.Name);

            switch (extension)
            {
                default:
                    {
                        return FileDefaultMenu;
                    }

                //case "zip":
                //case "gz":
                //case "gzip":
                //case "7z":
                //case "tar":
                //    {
                //        return FileArchiveMenu;
                //    }
            }
        }
    }
}